package generator;

import generator.meta.ClassMeta;
import generator.util.PackageScan;
import generator.util.ReflectUtil;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: sunguangzhu
 * Date: 13-8-9
 * Time: 上午9:23
 * To change this template use File | Settings | File Templates.
 */
public class ServiceImplGenerator extends Generator implements IGenerrator {
    @Override
    public void generate(String templateName, String packageName,String classPackage) throws Exception {
        Set<Class<?>> classes = PackageScan.getClasses(classPackage);
        for (Class<?> clazz : classes) {
            ClassMeta classMeta = new ClassMeta();
            classMeta.setPackageName(packageName);
            classMeta.setClassName(clazz.getSimpleName());
            classMeta.setLowerClassName(clazz.getSimpleName().substring(0,1).toLowerCase()+clazz.getSimpleName().substring(1));
            Map root = new HashMap();
            root.put("bean", classMeta);
            super.generate(root,templateName, classMeta.getClassName()+"ServiceImpl",packageName);        }
    }
}
